// Visibility and display utilities

// Responsive display utilities
@each $breakpoint, $variant in $responsive-variants {
  @include breakpoint($breakpoint) {
    @each $display in $display-values {
      .d#{$variant}-#{$display} { display: $display !important; }
    }
  }
}

.v-hidden { visibility: hidden !important; }
.v-visible { visibility: visible !important; }

// Hide utilities for each breakpoint
// Each hide utility only applies to one breakpoint range.
@media (max-width: $width-sm - 0.02px) {
  .hide-sm {
    display: none !important;
  }
}

@media (min-width: $width-sm) and (max-width: $width-md - 0.02px) {
  .hide-md {
    display: none !important;
  }
}

@media (min-width: $width-md) and (max-width: $width-lg - 0.02px) {
  .hide-lg {
    display: none !important;
  }
}

@media (min-width: $width-lg) {
  .hide-xl {
    display: none !important;
  }
}

// Show/Hide Viewport range utilities

.show-whenNarrow,
.show-whenRegular,
.show-whenWide,
.show-whenRegular.hide-whenWide {
  display: none !important;
}

.hide-whenNarrow,
.hide-whenRegular,
.hide-whenWide {
  display: block !important;
}

@media (max-width: $width-md - 0.02px) {
  .show-whenNarrow {
    display: block !important;
  }

  .hide-whenNarrow {
    display: none !important;
  }
}

@media (min-width: $width-md) {
  .show-whenRegular,
  .show-whenRegular.hide-whenWide {
    display: block !important;
  }

  .hide-whenRegular {
    display: none !important;
  }
}

// The width of a `wide` viewport range may change as we're finalizing
// the Primer primitives viewport ranges proposal
@media (min-width: $width-xl) {
  .show-whenWide {
    display: block !important;
  }

  .hide-whenWide,
  .show-whenRegular.hide-whenWide {
    display: none !important;
  }
}

/* Set the table-layout to fixed */
.table-fixed { table-layout: fixed !important; }

// Only display content to screen readers
//
// See: http://a11yproject.com/posts/how-to-hide-content/
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: rect(0 0 0 0);
  // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1241631
  overflow-wrap: normal;
  border: 0;
}

// Only display content on focus
.show-on-focus {
  position: absolute !important;

  &:not(:focus) {
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(1px, 1px, 1px, 1px) !important;
    border: 0 !important;
  }

  &:focus {
    z-index: 999;
  }
}
